package com.qf.service.impl;
/*
@author fu
@date 2022/3/1822:43
*/

import com.qf.mapper.UserMapper;
import com.qf.pojo.User;
import com.qf.service.UserService;
import com.qf.utils.MybatisUtils;

public class UserServiceImpl implements UserService {

    /**
     * 通过用户名校验是否可以注册
     * @param username 用户名
     * @return 返回true,可以注册;否则不能注册!
     */
    @Override
    public boolean checkUser(String username) {
        //调用数据访问接口 UserMapper
        //UserMapper userMapper = //mybatis动态代理获取
        //通过封装MybatisUtils工具类获取接口代理对象
        UserMapper userMapper = MybatisUtils.getMapper(UserMapper.class);
        User user = userMapper.selectUserByUserName(username);
        if(user==null){
            return  true ;//可以注册
        }
        return false;
    }
}
